//
//  WGHomePageController.m
//  WisdomGardon
//
//  Created by 董粟静 on 16/8/25.
//  Copyright © 2016年 Red Persimmon. All rights reserved.
//

#import "WGHomePageController.h"
#import "WGHomePageCell.h"
#import "CycleScrollView.h"

@interface WGHomePageController ()<CycleScrollViewDelegate>
{
    /**tabView**/
    __weak IBOutlet UITableView      *_tableView;
    /** tableView的头部 **/
    __weak IBOutlet UIView           *_headerView;
    /** banner图 **/
    __weak IBOutlet CycleScrollView  *_scrollerView;
    /** 选项位 **/
    __weak IBOutlet UIView           *_optionView;
}
@end

@implementation WGHomePageController

- (void)viewDidLoad
{
    [super viewDidLoad];
    /**设置导航栏**/
    [self createNav];
    /** 创建tableView头部 **/
    [self creatHeaderView];
    
}

#pragma mark - Private

/**设置导航栏**/
- (void)createNav
{
    [self setNavTitle:@"环保产业园"];
    //发布动态按钮
    UIButton *_addDynamicBtn = [UIButton buttonwithFrame:CGRectMake(0, 0, 18, 18) setImageName:@"btu-Add-to" setSelImageName:@"" target:self action:@selector(AddDynamicBtn)];
    [self setRightNavBtn:_addDynamicBtn];
    
}

/** 创建tableView头部 **/
- (void)creatHeaderView
{
     _headerView.height = 314;
    
//    //banner图
    NSMutableArray *bannerImgArray = [NSMutableArray arrayWithCapacity:0];
    [bannerImgArray addObject:[NSString stringWithFormat:@"http://img0.pconline.com.cn/pconline/digital/family/cul/1605/01.jpg"]];
    [bannerImgArray addObject:[NSString stringWithFormat:@"http://img0.pconline.com.cn/pconline/digital/family/cul/1605/01.jpg"]];
//    for (HomeBannerModel *model in _bannerArray) {
//        NSString *imgUrl = model.Img;
//        [bannerImgArray addObject:imgUrl];
//    }
    
    _scrollerView = [CycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 155) imagesGroup:bannerImgArray];
    _scrollerView.delegate = self;
    _scrollerView.pageControlAliment = PageContolAlimentCenter;
    [_headerView addSubview:_scrollerView];
    [_tableView setTableHeaderView:_headerView];
}



#pragma mark - UITableViewDataSource
/** 有几个分组 **/
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

/** 对应的分组显示多少行 **/
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *customCell = @"WGHomePageCell";
    WGHomePageCell *cell = [tableView dequeueReusableCellWithIdentifier:customCell];
    if (!cell) {
        cell = [WGHomePageCell loadFromXib];
    }
    
    //    PassengersModel *model = _passengersArray[indexPath.section];
    //    [cell cellWithModel:model];
    return cell;
}

#pragma mark - UITableViewDelegate
/** cell高度 **/
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 38;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
}


#pragma mark - CycleScrollViewDelegate
//banner点击
- (void)cycleScrollView:(CycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    DSLOG(@"首页banner第%ld张被点击了",(long)index);
}


#pragma mark - Btn

/** 发布动态按钮 **/
- (void)AddDynamicBtn
{
    
}

/** 政府政策 **/
- (IBAction)_onGovernmentPolicy:(id)sender
{
    NSLog(@"==========");
}

/** 园区概况 **/
- (IBAction)_onParkProfile:(id)sender
{
    
}

/** 招商引资 **/
- (IBAction)_onAttractInvestment:(id)sender
{
}

/** 园区企业 **/
- (IBAction)_onParkEnterprise:(id)sender
{
    NSLog(@"==========");
}

/** 园区服务 **/
- (IBAction)_onParkService:(id)sender
{
}

@end
